package com.zzti.serviceImpl;

import com.zzti.mapper.EquipmentMapper;
import com.zzti.pojo.Equipment;
import com.zzti.service.EquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

@Service
public class EquipmentServiceImpl implements EquipmentService {
    @Autowired
    private EquipmentMapper equipmentMapper;
    public static Integer count;

    @Override
    public List<Equipment> findAll(Map map) {
        List<Equipment> ls1 = equipmentMapper.selectList(map);
        map.remove("page");
        map.remove("limit");
        List<Equipment> ls2 = equipmentMapper.selectList(map);
        count = ls2.size();
        System.out.println(ls1.toString());
        return ls1;
    }

    @Override
    public Equipment findOne(Integer equId) {
        return equipmentMapper.selectById(equId);
    }

    @Override
    public Integer update(Equipment e) {
        return equipmentMapper.updateById(e);
    }

    @Override
    public List<Equipment> selectList(Map map) {
        return equipmentMapper.selectList(map);
    }

    @Override
    public Integer add(Equipment equipment) {
        return equipmentMapper.insert(equipment);
    }

    public Integer deleteByIds(Integer[] ids) {
        List<Integer> lids = Arrays.asList(ids);
        return equipmentMapper.deleteBatchIds(lids);
    }

    @Override
    public Integer changeEquDamage(String id) {
        return equipmentMapper.changeEquDamage(id);
    }

    @Override
    public Equipment findOneGoods(Integer id) {
        return equipmentMapper.selectById(id);
    }
}
